import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory("/home"),
  routes: [
    {
      path: "/",
      component: () => import("@/views/Home/home.vue"),
      meta: {
        title: "首页",
      },
    },
    {
      path: "/weather-forecast",
      component: () => import("@/views/weather-forecast/weather-forecast.vue"),
      meta: {
        title: "天气预报",
      },
    },

    {
      path: "/support",
      name: "emergency_support",
      component: () => import("@/views/emergency_support/index.vue"),
      meta: {
        title: "应急保障",
      },
      redirect: "/support/good-list",
      children: [
        {
          path: "/support/good-list",
          component: () =>
            import("@/views/emergency_support/good-list/good-list.vue"),
          meta: {
            title: "物资查询",
          },
        },
        {
          path: "/support/shops",
          component: () => import("@/views/emergency_support/shops/shops.vue"),
          meta: {
            title: "储备站点",
          },
        },
        {
          path: "/support/shops-map",
          component: () =>
            import("@/views/emergency_support/shops/shops-map.vue"),
          meta: {
            title: "储备地图",
          },
        },
        {
          path: "/support/detail",
          component: () =>
            import("@/views/emergency_support/detail/detail.vue"),
          meta: {
            title: "物资详情",
          },
        },
        {
          path: "/support/shops/shop-detail",
          component: () =>
            import("@/views/emergency_support/shop-detail/shop-detail.vue"),
          meta: {
            title: "储备详情",
          },
        },
      ],
    },
    {
      path: "/video-list",
      name: "video-list",
      component: () => import("@/views/video/list/list.vue"),
      meta: {
        title: "视频列表",
      },
    },
    {
      path: "/video",
      name: "video",
      component: () => import("@/views/video/video/video.vue"),
      meta: {
        title: "视频",
      },
    },

    {
      path: "/rain-forecast",
      name: "rain-forecast",
      component: () => import("@/views/rain-forecast/rain-forecast.vue"),
      meta: {
        title: "降雨预报图",
      },
    },
    {
      path: "/rainfall-distribution",
      name: "rainfall-distribution",
      component: () => import("@/views/rainfall-distribution/rainfall-distribution.vue"),
      meta: {
        title: "降雨分布图",
      },
      
    },
    {
      path: "/weather-radar",
      name: "weather-radar",
      component: () => import("@/views/weather-radar/weather-radar.vue"),
      meta: {
        title: "气象雷达",
      },
      
    },
    {
      path: "/weather-radar2",
      name: "weather-radar",
      component: () => import("@/views/weather-radar/weather-radar2.vue"),
      meta: {
        title: "气象雷达",
      },
    },
    {
      path: "/typhoon",
      name: "typhoon",
      component: () => import("@/views/typhoon/index.vue"),
      meta: {
        title: "台风",
      },
      
    },
  ],
});
// 监听路由变化
router.afterEach((to, from) => {
  // 根据路由中的meta设置文档标题
  if (to.meta && to.meta.title) {
    document.title = to.meta.title;
  }
});
export default router;
